package com.arpa.wms.controller;

import com.arpa.core.web.Result;
import com.arpa.ntocc.common.common.Page;
import com.arpa.ntocc.common.common.constant.StrConsts;
import com.arpa.ntocc.common.security.annotation.NeedLogin;
import com.arpa.wms.domain.dto.WavePickingItemDTO;
import com.arpa.wms.domain.entity.WavePickingItem;
import com.arpa.wms.service.IWavePickingItemService;
import io.swagger.annotations.*;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 波次 Controller
 * </p>
 *
 * @author rfwang
 * @since 2021-02-27
 */
@Api(tags = "波次信息")
@RestController
@RequestMapping(value = "/wavePickingItem", produces = "application/json;charset=UTF-8")
@Log4j2
public class WavePickingItemController {
    private final IWavePickingItemService wavePickingItemService;

    public WavePickingItemController(IWavePickingItemService wavePickingItemService) {
        this.wavePickingItemService = wavePickingItemService;
    }
    /**
     * 获取 波次信息 列表
     *
     * @param query
     * @return
     */
    @ApiOperation(value = "获取 波次详情 信息", notes = "获取 波次详情 信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "授权token", required = true, paramType = "header", dataType = "String", defaultValue = "Bearer "),
            @ApiImplicitParam(name = "deviceId", value = "设备id", paramType = "header", dataType = "string", defaultValue = "0000000000")
    })
    @ApiResponses(@ApiResponse(code = 0, message = "success", response = WavePickingItem.class))
    @NeedLogin
    @GetMapping()
    public Result list(WavePickingItemDTO query) {
        try {

            List<WavePickingItem> wavePickingItemList = wavePickingItemService.queryWavePickingItemList(query);
            Page returnPage = new Page(query.getPageNum(), query.getPageSize());
            returnPage.setRecords(wavePickingItemList);
            return Result.ok().data(returnPage);
        } catch (Exception e) {
            log.error(StrConsts.CATCH_MESSAGE,e);
            return Result.error(e.getMessage());
        }
    }
}
